package com.easou.ps.dk.utils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.junit.Test;

public class Configer {
	private static Map<String, String> configs = new HashMap<String, String>();
	static{
		try {
			InputStream in = new BufferedInputStream (new FileInputStream("config/sys.properties"));
			Properties properties = new Properties();
			properties.load(in);
			Enumeration<Object> keys = properties.keys();
//			ResourceBundle bundle = ResourceBundle.getBundle("sys");
//			Enumeration<String> keys = bundle.getKeys();
			while(keys.hasMoreElements()){
				String key = (String) keys.nextElement();
//				configs.put(key,bundle.getString(key));
				configs.put(key,properties.getProperty(key));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static String get(String key){
		return configs.get(key); 
	}
	
	@Test
	public void toTest(){
		try {
			InputStream in = new BufferedInputStream (new FileInputStream("config/sys.properties"));
			Properties properties = new Properties();
			properties.load(in);
			System.out.println(properties.get("debug"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
